<?php

declare(strict_types=1);

namespace App\Controller\Backend;

use App\Constants\SuccessCode;
use App\Model\Setting;
use App\Request\Backend\SettingEditRequest;
use App\Request\Backend\SettingIdRequest;
use App\Resource\BaseResource;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Contract\ResponseInterface;

class SettingManage
{
    public function getSettingConf(SettingIdRequest $request, ResponseInterface $response)
    {
        $conf = Setting::find($request->input('id'));

        return new BaseResource(SuccessCode::SUCCESS, $conf);
    }

    public function setSettingConf(SettingEditRequest $request, ResponseInterface $response)
    {
        $data = $request->validated();
        Setting::where('id', $request->input('id'))->update($data);

        return new BaseResource();
    }
}
